Skip to content

[FLINK-40492][table] Support casting from VARIANT to TIME and nanosecond timestamps - #29080

Merged
twalthr merged 5 commits into
apache:masterfrom
manner:FLINK-40492
Sep 10, 2026
Merged

twalthr merged 5 commits into
apache:masterfrom
manner:FLINK-40492

Conversation

@manner

@manner manner commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Extends VARIANT-to-scalar casting to the temporal types added in FLINK-40491: TIME and nanosecond-precision TIMESTAMP / TIMESTAMP_LTZ.
A VARIANT holding such a value can now be cast to TIME(3), TIMESTAMP(9), TIMESTAMP_LTZ(9) and to a string, with CAST failing / TRY_CAST returning NULL on a kind mismatch.

Brief change log

  • Enable CAST / TRY_CAST from VARIANT to TIME
  • Accept the TIMESTAMP_NS / TIMESTAMP_LTZ_NS storage kinds when casting to TIMESTAMP(p) / TIMESTAMP_LTZ(p)
  • Render TIME / TIMESTAMP_NS / TIMESTAMP_LTZ_NS when casting VARIANT to a string
  • Update the cast-support matrix in the docs

Verifying this change

This change added tests in CastRulesTest (VARIANTTIME/TIMESTAMP(9)/TIMESTAMP_LTZ(9), both storage kinds, plus string rendering), LogicalTypeCastsTest and CastRuleProviderTest.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes (new castable type pairs for VARIANT)
  • If yes, how is the feature documented? docs (cast-support matrix)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Claude Opus 4.8)

@flinkbot

flinkbot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@raminqaf raminqaf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @manner! Left some comments for improvements!

Comment thread docs/content.zh/docs/sql/reference/data-types.md
@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Sep 3, 2026

@twalthr twalthr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @manner. I left some last feedback from my side.

@twalthr twalthr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @manner.

@manner
manner force-pushed the FLINK-40492 branch 2 times, most recently from f1ccee0 to b0cdca4 Compare September 7, 2026 10:56
raminqaf

This comment was marked as outdated.

@raminqaf

raminqaf commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

One of the tests is failing in the CI

[ERROR]   BinaryVariantTest.testNanosecondPrecisionVariant:128

@manner

manner commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@flinkbot run azure

@raminqaf

Copy link
Copy Markdown
Contributor

@manner Please rebase master and let's see if the CI passes

@twalthr
twalthr merged commit 21f6a07 into apache:master Sep 10, 2026
@manner
manner deleted the FLINK-40492 branch September 10, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants